/**
 * @mathmodel library is an ArrayList of String words
 * 
 * @mathdef a String word isValid <=> word.length()=5 and word contains
 * 			only unique letters
 * 
 * @constraint (for all i : 0 <= i < |library| : library[i] isValid)
 *         
 * @initially library contains 50 hard-coded 5-letter words
 * 
 * @author Yao Wang
 *
 */
public interface AbstractDictionary {

	/**
	 * Checks that both words are present in the library and of the required
	 * length. Case insensitive.
	 * 
	 * @param word1
	 *            String to be checked against word2
	 * @param word2
	 *            String to be checked against word1
	 * @requires word1 and word2 isValid
	 * @ensures library is preserved
	 * 			word1 and word2 are preserved          
	 * @return the number of letters shared by the two words.
	 * @throws WordException to check to the format of the word
	 */
	int compareWords(String word1, String word2) throws WordException;

	/**
	 * Checks to see if the given word is in the dictionary. Case insensitive.
	 * 
	 * @param word the word to be checked against the library
	 * @requires word isValid
	 * @ensures library is preserved
	 * @return true if the word is in the library, false otherwise.
	 */
	boolean containsWord(String word);

	/**
	 * Returns the size of the library.
	 * @ensures library is preserved
	 * @return the number of words in the library.
	 */
	int size();

	/**
	 * Allows array-style read-only access to a library object members.
	 * 
	 * @param i
	 *            the index of the item to be accessed, valid between 0 and size
	 *            - 1
	 * @return a copy of the word found at the given index
	 */
	String getWord(int i);
}
